using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using T2.Logging.Data.Controllers.Interfaces;
using T2.Logging.Data.Entities.Interfaces;
using T2.Logging.Business.Entities.Interfaces;
using T2.Logging.Business.Entities;
using T2.Logging.Business.Builders;
using T2.Logging.Business.Directors.Interface;
using T2.Logging.Business.Entities.Search.Interfaces;

//--Change Management Control - Log Director  --**********************
//--Created By: trooks
//--Description: Log Director Class
//--Created Date: 03/07/2013 10:05:37
//--*************************************************************

namespace T2.Logging.Business.Directors
{
	public partial class Log_Director_biz : ILog_director_biz
	{
		
		public List<ILog_biz> Construct (ILog_biz _param, bool BuildUp, bool BuildDown)
		{
			Log_Builder build = new Log_Builder();
			List<ILog_biz> retVal = build.BuildParts(_param);
			foreach(ILog_biz item in retVal)
			{
				item.Application = BuildApplication(item, BuildUp, false);
				item.LogCategory = BuildLogCategory(item, BuildUp, false);
		}
			return retVal;
		}
		public List<ILog_biz> Construct (ILogSearch_biz _param, bool BuildUp, bool BuildDown)
		{
			Log_Builder build = new Log_Builder();
			List<ILog_biz> retVal = build.BuildParts(_param);
			foreach(ILog_biz item in retVal)
			{
				item.Application = BuildApplication(item, BuildUp, false);
				item.LogCategory = BuildLogCategory(item, BuildUp, false);
		}
			return retVal;
		}
		private IApplication_biz BuildApplication(ILog_biz _param, bool BuildUp, bool BuildDown)
		{
			IApplication_biz retVal = new Application_biz();
			if(BuildUp)
			{
			IApplication_biz ApplicationParam = new Application_biz();
			ApplicationParam.Action = "GetOne";
			ApplicationParam.ApplicationID = _param.ApplicationID;
			Application_Builder builder = new Application_Builder();
			retVal = builder.BuildParts(ApplicationParam).First();
			}
			return retVal;
		}
		private ILogCategory_biz BuildLogCategory(ILog_biz _param, bool BuildUp, bool BuildDown)
		{
			ILogCategory_biz retVal = new LogCategory_biz();
			if(BuildUp)
			{
			ILogCategory_biz LogCategoryParam = new LogCategory_biz();
			LogCategoryParam.Action = "GetOne";
			LogCategoryParam.LogCategoryID = _param.LogCategoryID;
			LogCategory_Builder builder = new LogCategory_Builder();
			retVal = builder.BuildParts(LogCategoryParam).First();
			}
			return retVal;
		}
	}
}